package com.bilibili.oneway;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class Producer {

    public static void main(String[] args) throws Exception {

    // 获取到producer对象
    DefaultMQProducer producer = new DefaultMQProducer("oneway_product_group");
    // 设置nameserver连接
    producer.setNamesrvAddr("localhost:9876");
    // 启动
    producer.start();
    // 创建消息对象，设置消息
    Message message = new Message("oneway", "hello", "我是达州的，达州西外的".getBytes(StandardCharsets.UTF_8));
    producer.sendOneway(message);
    //  关闭
    producer.shutdown();
    }
}
